package com.boot.consumer;

import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

/**
 * DESC: kafka消费者
 *
 * @author WangJie
 * @date Created in 2025-03-04 20:21
 */
@Component
public class KafkaConsumer {

    private static final Logger logger = LoggerFactory.getLogger(KafkaConsumer.class);

    @KafkaListener(topics = "topic-test", groupId = "my-group")
    public void listen(ConsumerRecord<String, String> record) {
        logger.info("Received message:{}, partition:{}, offset:{}", record.value(), record.partition(), record.offset());
    }

}

